package com.qinggeng.project.system.controller;

import java.util.List;

import com.qinggeng.project.system.service.UserBeatService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qinggeng.framework.aspectj.lang.annotation.Log;
import com.qinggeng.framework.aspectj.lang.enums.BusinessType;
import com.qinggeng.project.system.domain.UserBeat;
import com.qinggeng.framework.web.controller.BaseController;
import com.qinggeng.framework.web.domain.AjaxResult;
import com.qinggeng.common.utils.poi.ExcelUtil;
import com.qinggeng.framework.web.page.TableDataInfo;
/**
 * 用户捶一捶记录Controller
 * 
 * @author qinggeng
 * @date 2020-12-22
 */
@RestController
@RequestMapping("/system/beat")
public class UserBeatController extends BaseController
{
    @Autowired
    private UserBeatService userBeatService;

    /**
     * 查询用户捶一捶记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:beat:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserBeat userBeat)
    {
        startPage();
        List<UserBeat> list = userBeatService.selectUserBeatList(userBeat);
        return getDataTable(list);
    }

    /**
     * 导出用户捶一捶记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:beat:export')")
    @Log(title = "用户捶一捶记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(UserBeat userBeat)
    {
        List<UserBeat> list = userBeatService.selectUserBeatList(userBeat);
        ExcelUtil<UserBeat> util = new ExcelUtil<UserBeat>(UserBeat.class);
        return util.exportExcel(list, "beat");
    }

    /**
     * 获取用户捶一捶记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:beat:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(userBeatService.selectUserBeatById(id));
    }


    /**
     * 修改用户捶一捶记录
     */
    @PreAuthorize("@ss.hasPermi('system:beat:edit')")
    @Log(title = "用户捶一捶记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserBeat userBeat)
    {
        return toAjax(userBeatService.updateUserBeat(userBeat));
    }

    /**
     * 删除用户捶一捶记录
     */
    @PreAuthorize("@ss.hasPermi('system:beat:remove')")
    @Log(title = "用户捶一捶记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userBeatService.deleteUserBeatByIds(ids));
    }
}
